package io.renren.modules.m.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.m.entity.MtypeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.m.dao.MaterialDao;
import io.renren.modules.m.entity.MaterialEntity;
import io.renren.modules.m.service.MaterialService;
import org.springframework.web.bind.annotation.RequestParam;

@Service("materialService")
public class MaterialServiceImpl extends ServiceImpl<MaterialDao, MaterialEntity> implements MaterialService {
    @Autowired
    MaterialDao materialDao;
    @Override
    public List<MaterialEntity> listMaterial() {
//        String mtype =(String) params.get("key");
        return materialDao.listMaterial();
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String matid =(String) params.get("key");
        IPage<MaterialEntity> page = this.page(
                new Query<MaterialEntity>().getPage(params),
                new QueryWrapper<MaterialEntity>().like("mid",matid)
        );

        return new PageUtils(page);
    }

    @Override
    public void selectByPid(String pid, Page<MaterialEntity> page) {
        materialDao.selectByPid(pid,page);
    }

    @Override
    public List<MtypeEntity> listNum() {
        System.out.println(materialDao.listNum());
        return materialDao.listNum();
    }

    @Override
    public List<MaterialEntity> getMaterial(String matid) {
        System.out.println(materialDao.getMaterial(matid));
        return materialDao.getMaterial(matid);
    }


}